/** 
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */
package com.tompai.common.dao.impl;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.tompai.common.dao.BaseDao;
import com.tompai.common.model.SysPermission;

/**
 * @author liinux@qq.com
 * @date 2019年12月21日 15:11:59
 */
public interface SysPermissionMapper extends BaseDao<SysPermission> {

	/**
	 * 根据permissionIds查询权限信息
	 * 
	 * @author liinux@qq.com
	 * @date 2019/10/23
	 * @param permissionIds
	 * @return
	 */
	List<SysPermission> selectByIds(@Param("permissionIds") List<String> permissionIds);

	/**
	 * 根据用户id获取权限(资源)
	 * 
	 * @author liinux@qq.com
	 * @date 2019/4/14 1:33
	 * @param userId
	 * @return
	 */
	@Select(value = "select *\n" + "from t_sys_permission sp\n"
			+ "left join t_sys_role_permission_relation srpr on srpr.permission_id = sp.id\n"
			+ "left join t_sys_user_role_relation surr on srpr.role_id = surr.role_id\n"
			+ "where surr.user_id = #{userId};")
	List<SysPermission> getByUserId(@Param(value = "userId") String userId);
}